package acm.pta12;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

/**
 * todo:重点题
 */
public class 三足鼎立 {
    public static void main(String[] args) {
        Reader sc = new Reader();
        int n = sc.nextInt();
        long power = sc.nextLong();
        long[] arr = new long[n];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        long count = getCount(arr, power);
        System.out.println(count);
    }

    private static long getCount(long[] arr, long power) {
        long count = 0;
        Arrays.sort(arr);
        int end = arr.length - 1;
        for (int i = 0; i < arr.length - 1; i++) {
            long min = Math.abs(power - arr[i]);        //最小不能小于min
            int l = moreIndex(arr, i + 1, end, min);    //最小边界
            if (l == -1) {
                continue;
            }
            long max = power + arr[i];    //最大不能超过max
            int r = smallIndex(arr, i + 1, end, max);   //最大边界
            if (l > r) {
                continue;
            }
            count += r - l + 1;
        }
        return count;
    }

    //从 l-r 中找到第一个小于t的数
    public static int smallIndex(long[] arr, int l, int r, long t) {
        int start = l;
        while (l <= r) {
            int mid = l + ((r - l) >> 1);
            if (t <= arr[mid]) {    //小于等于都认为是小于
                r = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        if (r < start) {
            return -1;
        }
        return r;
    }

    //从 l-r 中找到第一个大于t的数
    public static int moreIndex(long[] arr, int l, int r, long t) {
        while (l <= r) {
            int mid = l + ((r - l) >> 1);
            if (t >= arr[mid]) {    //大于等于都认为是大于
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
        if (l >= arr.length) {
            return -1;
        }
        return l;
    }

//    static {
//        long[] nums = {0, 1, 2, 3, 4, 5};
//        int i = smallIndex(nums, 0, nums.length - 1, 10);
//    }

    static
    class Reader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");

        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {    //内存中没有
                String nextLine = innerNextLine();
                if (nextLine == null) {     //且没有下一行
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);  //读入一行
            }
            return true;
        }

        public String nextLine() {
            tokenizer = new StringTokenizer("");    //清空内存中的字符
            return innerNextLine();
        }

        public void clear() {
            tokenizer = new StringTokenizer("");
        }

        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
//    public BigInteger nextBigInt() {
//        return new BigInteger(next());
//    }
    }

}
